package com.itheima.controller.backend.security.security;

import com.itheima.Service.ReportService;
import com.itheima.common.entity.Result;
import com.itheima.pojo.MemberReport;
import com.itheima.pojo.ReportData;
import com.itheima.pojo.SetMealData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("report")
public class ReportController {
   @Autowired
   private ReportService reportService;

    @GetMapping("/getMemberReport")
    public Result getMemberReport(){
        MemberReport memberReport = reportService.getMemberReport();
        return new Result(true,"获取会员统计数据成功",memberReport);
    }

    @GetMapping("getSetmealReport")
    public Result getSetmealReport(){
       SetMealData setMealData= reportService.getSetmealReport();
       return new Result(true,"获取套餐统计数据成功",setMealData);
    }

    @GetMapping("getBusinessReportData")
    public  Result getBusinessReportData(){
        ReportData reportData = reportService.getBusinessReportData();
        return new Result(true,"获取运营数据成功",reportData);
    }

    @GetMapping("exportBusinessReport")
    public Result exportBusinessReport(HttpServletResponse response) throws IOException {
        reportService.exportBusinessReport( response);
        return new Result(true,"导出运营数据成功");
    }
}
